<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" th:href="@{/layui/css/layui.css}">
    <link rel="stylesheet"  th:href="@{/css/file.css}" />
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script th:src="@{/lib/layui/layui.js}" charset="utf-8"></script>
</head>
<body>
<form class="layui-form" th:action="@{/tea/exam/content/updatesubmit}" enctype="multipart/form-data" method="post">
    <input type="hidden" name="id" th:value="${content.getId()}">
    <input type="hidden" name="type_id" th:value="${content.getType_id()}">
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">所属试卷</label>
        <div class="layui-input-inline">
            <select name="exam_id" lay-verify="required">
                <option value=""></option>
                <option th:each="exam:${exams}" th:value="${exam.getId()}" th:text="${exam.getName()}" th:selected="${content.getExam_id()==exam.getId()}"></option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">题目</label>
        <div class="layui-input-block">
            <input type="text" name="subject" required th:value="${content.getSubject()}" lay-verify="required"  autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item" th:if="${content.getType_id()==1||content.getType_id()==2}">
        <label class="layui-form-label">选项A</label>
        <div class="layui-input-block">
            <input type="text" name="answer_a" required th:value="${content.getAnswer_a()}" lay-verify="required"  autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item" th:if="${content.getType_id()==1||content.getType_id()==2}">
        <label class="layui-form-label">选项B</label>
        <div class="layui-input-block">
            <input type="text" name="answer_b" required th:value="${content.getAnswer_b()}" lay-verify="required"  autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item" th:if="${content.getType_id()==1||content.getType_id()==2}">
        <label class="layui-form-label">选项C</label>
        <div class="layui-input-block">
            <input type="text" name="answer_c" required th:value="${content.getAnswer_c()}" lay-verify="required"  autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item" th:if="${content.getType_id()==1||content.getType_id()==2}">
        <label class="layui-form-label">选项D</label>
        <div class="layui-input-block">
            <input type="text" name="answer_d" required th:value="${content.getAnswer_d()}" lay-verify="required"  autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item" id="picture_a" th:if="${content.getType_id()==4}">
        <label class="layui-form-label">题目图片</label>
        <div class="layui-input-block">
            <a href="javascript:;" class="file">格式.jpg/.png
                <input type="file" name="img"  lay-verify="image|required" autocomplete="off" id="user-image" >
            </a>
        </div>
    </div>
    <div class="layui-form-item" id="picture_b" th:if="${content.getType_id()==4}">
        <label class="layui-form-label">预览</label>
        <div class="layui-input-block">
            <!-- 显示图像预览 -->
            <img style="width: 300px;height: 200px;" class="ui big bordered image" id="img2">
        </div>
    </div>
    <input type="hidden" id="myimg" th:value="${content.getImage()}">
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit  type="submit">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
</body>
<script>
    //Demo
    layui.use('form', function(){
        var form = layui.form;

    });

    $(document).ready(function () {
        layui.use('laydate', function(){
            var laydate = layui.laydate;

            //执行一个laydate实例
            laydate.render({
                elem: '#test1'
                ,type: 'datetime'//指定元素
            });
        });
        var myimg=$('#myimg').val();
        $('#img2').attr('src', 'https://wk2020.oss-cn-shenzhen.aliyuncs.com/'+ myimg);
    })
</script>
</html>